package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.pojo.TbProdAtta;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description : TODO
 * @Author QiHainan
 * @Create 2025/7/19 8:43
 * @Version 1.0
 */
@RestController
@RequestMapping("/prod/index")
public class IndexController {
    @Autowired
    TbProdService tbProdService;

    /**
     * 获取商品列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getProdList")
    public R getProdList(@RequestBody PageInfoVo pageInfoVo){
        return tbProdService.getProdList(pageInfoVo);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @PostMapping("/deleteBatch")
    public R deleteBatch(@RequestBody List<Integer> ids){
        return tbProdService.deleteBatch(ids);
    }

    /**
     * 单删
     * @param prodId
     * @return
     */
    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable("prodId") Integer prodId){
        return tbProdService.deleteProd(prodId);
    }

    /**
     * 获取分类列表数据
     * @return
     */
    @PostMapping("/getTypeInfo")
    public R getTypeInfo(){
        return tbProdService.getTypeInfo();
    }

    /**
     * 获取字典表数据
     * @param typeId
     * @return
     */
    @PostMapping("/getDictList/{typeId}")
    public R getDictList(@PathVariable("typeId") Integer typeId){
        return tbProdService.getDictList(typeId);
    }

    /**
     * 添加商品
     * @param tbProd
     * @return
     */
    @PostMapping("/addProd")
    public R addProd(@RequestBody TbProd tbProd){
        return tbProdService.addProd(tbProd);
    }

    /**
     * 添加商品附件
     * @param tbProdAtta
     * @return
     */
    @PostMapping("/addProdAtta")
    public R addProdAtta(@RequestBody TbProdAtta tbProdAtta){
        return tbProdService.addProdAtta(tbProdAtta);
    }

    /**
     * 获取商品信息列表
     * @return
     */
    @PostMapping("/getProdInfoList")
    public R getProdInfoList(){
        return tbProdService.getProdInfoList();
    }

    /**
     * 商品信息分页列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getProdInfoPage")
    public R getProdInfoPage(@RequestBody PageInfoVo pageInfoVo){
        return tbProdService.getProdInfoPage(pageInfoVo);
    }

    /**
     * 添加商品信息
     * @param tbProdInfo
     * @return
     */
    @PostMapping("/addProdInfo")
    public R addProdInfo(@RequestBody TbProdInfo tbProdInfo){
        return tbProdService.addProdInfo(tbProdInfo);
    }
}
